using System;
using System.Collections.Generic;
using System.Text;

namespace Tarea5
{
    class ViewTextMode : ViewInterface, ObserverInterface
    {
        private ControllerInterface controller;
        private ModelInterface model;
        private string title;

        public ViewTextMode()
        {}


        public void Initialize(string title, ControllerInterface controller)
        {
            this.controller = controller;
            this.title = title;
        }


        public void SetModel(string title, ModelInterface model)
        {
            if (this.model != null)
                model.RemoveObserver(this);

            this.model = model;
            this.title = title;

            model.RegisterObserver(this);

            Console.WriteLine(title);
            Console.WriteLine();
        }

        public void Update(StateInterface state, string msg, string info)
        {
            Console.WriteLine("-----------------------------------------------------------");

            for(int i=0; i<state.Board.GetLength(0); i++)
            {
                for (int j = 0; j < state.Board.GetLength(1); j++)
                {
                    if(state.Board[i, j] == 0)
                        Console.Write("X\t");
                    else
                        Console.Write(state.Board[i, j] + "\t");
                }
                Console.WriteLine();
            }

            /*
            for (int i = 0; i < state.GoalBoard.GetLength(0); i++)
            {
                for (int j = 0; j < state.GoalBoard.GetLength(1); j++)
                {
                    if (state.GoalBoard[i, j] == 0)
                        Console.Write("X\t");
                    else
                        Console.Write(state.GoalBoard[i, j] + "\t");
                }
                Console.WriteLine();
            }
            */

            Console.WriteLine();
            Console.WriteLine(msg);
            Console.WriteLine(info);
            Console.WriteLine();
            Console.WriteLine("-----------------------------------------------------------");
        }
    }
}
